package com.example.demo.singleton;

/**
 * @author void
 * @date 2022/2/17 16:43
 * @desc 懒汉式，线程安全
 */
public class Singleton2 {
    
    private static Singleton2 instance;
    
    private Singleton2() {}
    
    public static synchronized Singleton2 getInstance(){
        if(instance==null){
            instance = new Singleton2();
        }
        return instance;
    }
}
